<?php
/**
 * Created by PhpStorm
 * User: honglin
 * Date: 2022/9/2
 * Time: 下午3:07
 */

namespace Form\Diy;


use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\PostApi;
use Yj\ColumnBuilder\Column;
use Yj\Form\BaseForm;
use Yj\Form\Elm;

/**
 * @ApiController(prefix="form/diy/diy")
 */
class Diy extends BaseForm
{
    protected $yjCode = 'diy/diy';
    /**
     * @PostApi(path="config",description="配置")
     */
    public function config()
    {
        $this->_config();
    }

    public function getColumn()
    {
        $colum = Column::create();
        $colum->setRules([
            Column::txt()->setLabel('页面ID')->setProp('id'),
            Column::txt()->setLabel('模板名称')->setProp('name'),
            Column::txt()->setLabel('添加时间')->setProp('create_time'),
            Column::txt()->setLabel('更新时间')->setProp('update_time')
        ]);
        return $colum->toArray();
    }

    /**
     * @PostApi(path="update",description="添加")
     */
    public function update()
    {
        $form = Elm::createForm($this->getRoute('add'));
        $form->setRule([
            Elm::input('id', '页面ID')->required(),
            Elm::input('name', '模板名称')->required(),
            Elm::input('create_time', '添加时间')->required(),
            Elm::input('update_time', '更新时间')->required(),
        ]);
        $lists = $form->setTitle('添加模板')->formData([]);
        _SUCCESS(formToData($lists));
    }


}